D4451: Fix copy/move issues casude by __tuple_leafs's converting constructor git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213888 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__tuple b/include/__tuple index de35cb8..ee5b916 100644 --- a/include/__tuple +++ b/include/__tuple
@@ -27,6 +27,32 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// __lazy_and + +template <bool _Last, class ..._Preds> +struct __lazy_and_impl; + +template <class ..._Preds> +struct __lazy_and_impl<false, _Preds...> : false_type {}; + +template <> +struct __lazy_and_impl<true> : true_type {}; + +template <class _Pred> +struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {}; + +template <class _Hp, class ..._Tp> +struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {}; + +template <class _P1, class ..._Pr> +struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; + +// __lazy_not + +template <class _Pred> +struct __lazy_not : integral_constant<bool, !_Pred::type::value> {}; + + template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size; template <class _Tp>
diff --git a/include/tuple b/include/tuple index e98ae72..c3fdd40 100644 --- a/include/tuple +++ b/include/tuple
@@ -210,7 +210,13 @@ "Attempted to default construct a reference element in a tuple");} template <class _Tp, - class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type> + class = typename enable_if< + __lazy_and< + __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>> + , is_constructible<_Hp, _Tp> + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : value(_VSTD::forward<_Tp>(__t)) @@ -316,7 +322,13 @@ : _Hp(__a) {} template <class _Tp, - class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type> + class = typename enable_if< + __lazy_and< + __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>> + , is_constructible<_Hp, _Tp> + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : _Hp(_VSTD::forward<_Tp>(__t)) {} @@ -336,6 +348,9 @@ explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t) : _Hp(_VSTD::forward<_Tp>(__t), __a) {} + __tuple_leaf(__tuple_leaf const &) = default; + __tuple_leaf(__tuple_leaf &&) = default; + template <class _Tp> _LIBCPP_INLINE_VISIBILITY __tuple_leaf&